// objectFactory(name,'csk','18)

function objectFactory(){
    const obj = new Object()
    const Constructor = [].shift.call(arguments);
    console.log(Constructor)
    obj.__proto__ = Constructor.prototype;

    const ret  = Constructor.apply(obj,arguments)

    return typeof ret === "object" ? ret : obj
}

function Person(name) {
    this.name = name
  }
  Person.prototype.say = function () {
    console.log(`i'm ${this.name}`)
  }
//let objdef = objectFactory(Person)  Person { name: undefined }
let objdef = objectFactory(Person,'csk','18') //Person { name: 'csk' }
console.log(objdef)